//
// Created by T758 on 2021/11/28.
//
#pragma once
#include <iostream>

#define LOG(message) (std::cout << message << std::endl)

// tokens and classes (operators last and in precedence order)
enum {
  Num = 128, Fun, Sys, Glo, Loc, Id,
  Char, Else, Enum, If, Int, Return, Sizeof, While,
  Assign, Cond, Lor, Lan, Or, Xor, And, Eq, Ne, Lt, Gt, Le, Ge, Shl, Shr, Add, Sub, Mul, Div, Mod, Inc, Dec, Brak
};

// opcodes (ISA)
enum {
  LEA, IMM, JMP, JSR, BZ, BNZ, ENT, ADJ, LEV, LI, LC, SI, SC, PSH,
  OR, XOR, AND, EQ, NE, LT, GT, LE, GE, SHL, SHR, ADD, SUB, MUL, DIV, MOD,
  OPEN, READ, CLOS, PRTF, MALC, FREE, MSET, MCMP, EXIT
};

// types
enum { CHAR, INT, PTR };

// identifier offsets (since we can't create an ident struct)
enum { Tk, Hash, Name, Class, Type, Val, HClass, HType, HVal, Idsz };

void Foo() {
  int i, t1, t2, n, nextTerm;
  i = 0;
  t1 = 0;
  t2 = 1;
  n = 15;
  LOG("------------------- Test start -------------------");
  std::cout << "斐波那契数列 in %d: " << n << std::endl;

  while (i <= n) {
    std::cout << " , " << t1;
    nextTerm = t1 + t2;
    t1 = t2;
    t2 = nextTerm;
    ++i;
  }
  std::cout << "The end!" << std::endl;
}
